<%@page import="com.ym.b2b.cache.configcache.WebAppConfig"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="b" uri="/b2b-tags"%>
<script language="JavaScript" type="text/javascript" src="<c:url value="/resources/js/web/tool-tip.js" />"></script>
<link href="<c:url value="/views/jsp/product/shoppingcart/css/select.css" />" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript" src="<c:url value="/views/jsp/product/shoppingcart/js/jQuery-shopping.js" />"></script>
<script language="JavaScript" type="text/javascript" src="<c:url value="/resources/js/web/scroll_search.js" />"></script>
 
<script>
setFocus(4);
</script>
 <!-- search  begin -->
<div style="margin: 0 auto;width: 1190px;">
<div class="mianbox">
<!-- 搜索结果 -->
  <div class="weizhi fl">
	<h2 id="poplogin">首页</h2>
	<span>&gt;</span>
	<h2><a href="<c:url value="/product/searchProduct.s" />">可供品种</a></h2>
	<c:if test="${not empty result.data.svo.productTypeName }">
		<span>&gt;</span>
		<div class="weizhi_ss fl" style="border: none">
			<i>
				<a href="javascript:searchkeyClose('inc_productTypeCode',2)" style="color: #F50">${result.data.svo.productTypeName }<img src="<c:url value="/resources/images/product_list/closeSort.png" />"></a>
			</i>
		</div>
	</c:if>
	<div class="weizhi_ss fl"  >
		<input class="txt fl" type="text" id="s_chsName" value="${result.data.svo.chsName }" >
		<input class="btn fl" type="button" onclick="setChsNameForSearch()">
	</div>
	<div class="shouqi fr fb" onClick="return gengduoShow();">- 收起</div>
	<div class="tiao fr">
		<font>共找到</font>
		<font style=" color:#8f0100; font-weight:bold;">${result.page.totalRow}</font>
		<font>条相关产品</font>
	</div>
  </div>
<!-- 搜索结果 -->
		  
<!-- 分类搜索 开始 -->
	  <div class="search_list fl">
	        <b:showBrand outResponseAttrName="brand" />
			<div class="search_c fl" id="searchBrand">
				<span>品牌</span>
				<div class="gengduo fr"><a  href="javascript:void(0);" id="brandMore"  onclick="toggle(this);">更多</a></div>
				<div class="right fl" id="brandMore_content">
					<c:forEach var="childType" items="${brand.data.brandList }">
						<em><a href="<%=request.getContextPath() %>/product/searchProduct.s?productTypeCode=${result.data.svo.productTypeCode}&brandId=${childType.brandId}"   brandId="${childType.brandId}">${childType.brandChsName } </a></em>
					</c:forEach>
				</div>
			</div>
	  		<b:showProductCategory outResponseAttrName="pType1" />
			<c:forEach var="type" items="${pType1.data.type }" varStatus="varstatus">
				<div class="search_c fl">
					<span>${type.productTypeName }</span>
									<div class="gengduo fr"><a  href="javascript:void(0);" id="test${varstatus.index }"  onclick="toggle(this);">更多</a></div>
					<div class="right fl" id="test${varstatus.index }_content">
						<c:forEach var="childType" items="${type.emBProductTypeList }">
							<em><a href="<%=request.getContextPath() %>/product/searchProduct.s?productTypeCode=${childType.productTypeCode}&brandId=${result.data.svo.brandId}"   id="${childType.productTypeCode}">${childType.productTypeName } </a></em>
						</c:forEach>
					</div>
				</div>
			</c:forEach>
		  </div>
<!-- 分类搜索 结束 -->
		   
		   
<!-- 广告 -->
<%-- <div class="mian_search fl" id="nav_left_layout">
		<div class="top fl">
			<span>大家都在找：</span>
			<em style="border:0;"><a href="javascript:setSearchValueForSearch('阿莫西林胶囊');">阿莫西林胶囊</a></em>
			<em><a href="javascript:setSearchValueForSearch('肠胃用药');">肠胃用药</a></em>
			<em><a href="javascript:setSearchValueForSearch('复方氨酚烷胺胶囊');">复方氨酚烷胺胶囊</a></em>
			<em><a href="javascript:setSearchValueForSearch('强力枇杷露');">强力枇杷露</a></em>
			<em><a href="javascript:setSearchValueForSearch('避孕套');">避孕套</a></em>
			<em><a href="javascript:setSearchValueForSearch('氯雷他定片');">氯雷他定片  </a></em>
			<em><a href="javascript:setSearchValueForSearch('健胃消食片');">健胃消食片  </a></em>
		</div>
		<div class="ad_list fl">
			<a href="" target="_blank"><img src="<c:url value="/resources/images/product_list/ad_01.jpg" />"></a>
			<a href="" target="_blank"><img src="<c:url value="/resources/images/product_list/ad_02.jpg" />"></a>
			<a href="" target="_blank"><img src="<c:url value="/resources/images/product_list/ad_03.jpg" />"></a>
			<a href="" target="_blank"><img src="<c:url value="/resources/images/product_list/ad_04.jpg" />"></a>
			<a href="" target="_blank"><img src="<c:url value="/resources/images/product_list/ad_05.jpg" />"></a>
			<a href="" target="_blank"><img src="<c:url value="/resources/images/product_list/ad_06.jpg" />"></a>
		</div>
		
	</div> --%>
<!-- 广告 结束 -->
		  <div class="paixu_xz fl" id="search_condition">
			<div class="paixu_xuanzhe fl">
				<ul>
					<li><a class="<c:choose> <c:when test="${empty result.data.svo.orderByType}">dq</c:when><c:otherwise></c:otherwise> </c:choose>"  href="javascript:searchProductOrder('')">综合</a></li>
					<li><a class="<c:choose> <c:when test="${result.data.svo.orderByType eq 'SALES'}">dq</c:when><c:otherwise></c:otherwise> </c:choose>"  href="javascript:searchProductOrder('SALES')"  ><span>销量</span></a></li>
					<li><a class="<c:choose> <c:when test="${result.data.svo.orderByType eq 'NEW'}">dq</c:when><c:otherwise></c:otherwise> </c:choose>"  href="javascript:searchProductOrder('NEW')"  ><span>最新</span></a></li>
					<li><a class="<c:choose> <c:when test="${result.data.svo.orderByType eq 'STOCK'}">dq</c:when><c:otherwise></c:otherwise> </c:choose>"  href="javascript:searchProductOrder('STOCK')"  ><span>库存</span></a></li>
					<li class="jiage"><a href="javascript:searchProductOrder('PRICE')"  class="<c:choose> <c:when test="${result.data.svo.orderByType eq 'PRICE_DESC'}">dq</c:when><c:when test="${result.data.svo.orderByType eq 'PRICE_ASC'}">pt</c:when> </c:choose>"><span>价格</span></a></li>
				</ul>
				 
				<div class="ye fr">
						<c:if test="${result.page.page gt  1 }">
							<div class="xia fl"><a href="${result.page.pageUrl }&page=${result.page.page-1}">上一页</a></div>
							<a href="${result.page.pageUrl }&page=${result.page.page-1}"  class="prev"></a>
						</c:if>
						<c:if test="${result.page.totalPage gt result.page.page}">
							<div class="shang fl"><a href="${result.page.pageUrl }&page=${result.page.page+1}">下一页</a></div>
						</c:if>
				</div>
				<div class="tiao fr">
					<font>共</font>
					<font style=" color:#ac1d1f; ">${result.page.totalRow}</font>
					<font>个商品</font>
					<font style="margin-left:14px; display:inline;">${result.page.page}/${result.page.totalPage}</font>
				</div>
			 </div>
		</div>
	<form action="<%=request.getContextPath() %>/product/searchProduct.s" method="post" name="filterForm" id="filterForm"  >
		  <input type="hidden" id="filterFormSearchWhere" name="searchWhere" value="${result.data.svo.searchWhere}">
		  <input type="hidden" name="productTypeCode" id="inc_productTypeCode" value="${result.data.svo.productTypeCode}">
		  <input type="hidden" name="orderByType" id="orderByType" value="${result.data.svo.orderByType}"> 
		  <input type="hidden" name="brandId" id="brandId" value="${result.data.svo.brandId}">
	</form>
</div>

<!-- search  begin -->

<div class="mianbox">
<div id="M-main-b" style="background: white;">
 	<c:forEach var="product" items="${result.rows }" varStatus="varstatus" >
 	 
	<div class="M-main-list" style="width: 980px;<c:if test="${varstatus.count%2 == '0'}">background: #fafafa;</c:if>">
		<div class="M-main-A left">
			<div class="M-main-A-a">
				<a href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }" target="_blank" name="<%=WebAppConfig.getPicPath() %>${product.smallPic}" class="commtooltip">
				 	<img src="<%=WebAppConfig.getPicPath() %>${product.smallPic}"  width="65" height="65" />
				</a>
				<span class="M-list-color-1"></span>
			</div>
			<div class="M-main-A-b">
				<h3>
				<a href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }" target="_blank" onmouseover="javascript:showTip(this, 'roomtip_${varstatus.index}', event);" onmouseout="javascript:hideddrivetip()">
				<!--   小图标示例 促销 团购 等
				<c:if test="${varstatus.index le 5}"><img src="<c:url value="/resources/images/damaichang/tuan.gif"  />" width="22px" height="22px"/></c:if>
				<c:if test="${varstatus.index ge 5}"><img src="<c:url value="/resources/images/damaichang/qiang.gif"  />" width="22px" height="22px"/></c:if>
				<img src="<c:url value="/resources/images/product_list/cu.jpg" />" />
				-->
				${product.chsName } 
				<c:if test="${not empty product.viewUrl}">
					<a href="javascript:showProduct3d('3d','<c:url value='${product.viewUrl}' />')" style="color: red;font-weight: 700;">[3D]</a>
				</c:if>
			 
				 </a>
				 </h3>
				 
				<p>规格： ${product.productSpec }</p>
				<p><a href="<c:url value="/product/searchProduct.s" />?producingName=${product.producingName }">${product.producingName }</a></p>
			</div>
		</div>
		<div class="M-main-B left">
			<p>中包装：${product.minPackingNumber } ${product.packingUnit }</p>
			
			<p>大包装：${product.packingAmount } ${product.packingUnit }</p>
			
			<p>起买：
				 <c:if test="${product.minBuy gt 0}">
	                    ${product.minBuy}
	             </c:if>
	             <c:if test="${product.minBuy == 0}">
	                    1
	             </c:if>
			   ${product.packingUnit }
			</p>
		</div>
		 
		<div class="M-main-D left" style="width: 20%;">
			<p>零售价：¥${product.retailPrice}  </p>
			<p>会员价：<c:if test="${empty sessionScope.WEB_USER_TOKEN}"><a href="javascript:layer.login();" >登录查看</a></c:if><c:if test="${not empty sessionScope.WEB_USER_TOKEN}">¥<span>${product.salePrice }</span></c:if>  </p>
			<p>库存：
<%--                     <c:if test="${not empty sessionScope.WEB_USER_TOKEN}">
                        <c:if test="${product.stockNum ge 100 }">
                            有货
                        </c:if>
                        <c:if test="${product.stockNum le 100 }">
                           ${product.stockNum}
                        </c:if>
                    </c:if>
					<c:if test="${empty sessionScope.WEB_USER_TOKEN}">
					 --/--
					</c:if> --%>
					<c:if test="${not empty sessionScope.WEB_USER_TOKEN}">
                           ${product.stockNum}
                    </c:if>
					<c:if test="${empty sessionScope.WEB_USER_TOKEN}">
					 	登录查看
					</c:if>
					
			</p>
		</div>
		<div class="M-main-E left">
					<input tabindex="${varstatus.index}" type="text" id="amount_${varstatus.index }" name="addShoppingCartinput"  oldamount="${product.amount}" productCode="${product.productCode}" bId="${varstatus.index }" style="width:60px" class="inputtxt2 addShoppingCartinput" onkeydown="addShoppingCartkd13(this,${varstatus.index })"  title="请输入购买数量，直接加入购物车"   >
				 x  <c:if test="${product.minBuy gt 0}">
		                 ${product.minBuy}
		             </c:if>
		             <c:if test="${product.minBuy == 0}">
		                 1
		             </c:if>  ${product.packingUnit}
		            
				    <a title="加入购物车" href="###" indexId="${varstatus.index }" productCode="${product.productCode}" amount="${product.stockNum}" img="<%=WebAppConfig.getPicPath() %>${product.smallPic}"    class="baseBg Q-buy-btn" id="buy-s-${varstatus.index }">加入购物车</a>
				 
		</div>
	</div>
	
			<!-- 商品扩展信息 -->
                <div id="roomtip_${varstatus.index}"  style="display:none;z-index: 600px;">    
	                   <div style="float: left;width: 260px;background-color:white; color:#fff', '#F26C4F">
	                   	   <c:if test="${not empty product.promoDesc}" >
	                   	   		<div><b style="font-weight: bold;color: red;">${product.promoDesc } </b></div>
	                       </c:if>
		                   <div><b>品名：</b>${product.productName }</div>
		                   <div><b>规格：</b>${product.productSpec }</div>
	                       <div><b>所属范围：</b>${product.businesscope }</div>
		                   <div><b>药品编号：</b>${product.productCode }</div>    
		                   <div><b>单位：</b>${product.packingUnit }</div>     
		                   <div><b>大包装：</b>${product.packingAmount }</div>   
		                   <div><b>注册商标：</b>${product.brand }</div>   
		                   <div><b>建议零售价：</b>￥${product.retailPrice }</div>  
		                   <div><b>批准文号/注册证号：</b>${product.authorizeNumber }</div>    
	                   </div>  
                 </div>
                 <!-- 效果div end -->
	</c:forEach>
	 <c:import url="/views/jsp/product/import/product_page_info.jsp" />
</div>	


<!-- 右侧推荐 -->
<div class=" product_right fr mt8">
		 
		<div class="ranking fl mt8">
        	<div class="ran_tit fb fl">一周热销排行 </div>
			<ul id="ranks">
			
				<b:showProduct limitRow="7" isTop="1"  outResponseAttrName="newP"/>
				<c:forEach items="${newP.rows }" var="p1" varStatus="ind">
				<c:if test="${ind.index eq '0'}" >
					<li class="dq" style="border:0;">
				</c:if>
				<c:if test='${ind.index ge 0}' >
					<li class="pt">
				</c:if>
					<i>${ind.index}</i><div class="name fl"><a href="<c:url value="/product/showProductDetail.s" />?productCode=${p1.productCode}">${p1.chsName}</a></div>
					<span>
						<div class="fl img">
							<a href=""><img src="<%=WebAppConfig.getPicPath() %>${p1.smallPic }"></a>
						</div>
						<div class="img_name fr"><a href="<c:url value="/product/showProductDetail.s" />?productCode=${p1.productCode}">${p1.chsName}</a></div>
						<div class="jiage fr">￥${p1.salePrice}</div>
					</span>
				</li>
				</c:forEach>
			</ul>
      	</div>
		<div class="resou fl mt8">
        	<div class="ran_tit fb fl">搜索热门榜 </div>
			<ul id="resou">
				<li style="border:0;">
					<i>1</i><div class="name fl"><a href="javascript:setSearchValueForSearch('阿莫西林');">阿莫西林</a></div>
				</li>
				<li>
					<i>2</i><div class="name fl"><a href="javascript:setSearchValueForSearch('复方氨酚烷胺片');">复方氨酚烷胺片</a></div>
				</li>
				<li>
					<i>3</i><div class="name fl"><a href="javascript:setSearchValueForSearch('人工甲硝唑');">人工甲硝唑</a></div>
				</li>
				<li>
					<b>4</b><div class="name fl"><a href="javascript:setSearchValueForSearch('感冒');">感冒</a></div>
				</li>
				<li>
					<b>5</b><div class="name fl"><a href="javascript:setSearchValueForSearch('祛斑');">祛斑</a></div>
				</li>
				<li>
					<b>6</b><div class="name fl"><a href="javascript:setSearchValueForSearch('祛风湿');">祛风湿</a></div>
				</li>
				<li>
					<b>7</b><div class="name fl"><a href="javascript:setSearchValueForSearch('金钱草颗粒');">金钱草颗粒</a></div>
				</li>
				<li>
					<b>8</b><div class="name fl"><a href="javascript:setSearchValueForSearch('罗红霉素');">罗红霉素</a></div>
				</li>
				<li>
					<b>9</b><div class="name fl"><a href="javascript:setSearchValueForSearch('肾宝片');">肾宝片</a></div>
				</li>
				<li>
					<b>10</b><div class="name fl"><a href="javascript:setSearchValueForSearch('避孕套');">避孕套</a></div>
				</li>
			</ul>
		</div>		
	</div>
<!-- 右侧最贱结束 -->	
</div>	

 

<script type="text/javascript">
 	
$(function(){
   //分类选中
   if('${result.data.svo.productTypeCode}'!=''){
		$("#"+'${result.data.svo.productTypeCode}').addClass("sel");
		$("#"+'${result.data.svo.productTypeCode}').attr("href","javascript:searchkeyClose('inc_productTypeCode',2);");
   }
   //分类选中
   if('${result.data.svo.brandId}'!=''){
		$("#searchBrand a").each(function(i){
			if($(this).attr("brandId")=='${result.data.svo.brandId}'){
				$(this).addClass("sel");
				$(this).attr("href","javascript:searchkeyClose('brandId',2);");
			}
		});
		
		
   }
   //调用shoping加入购物车 效果函数
   $('.Q-buy-btn').shoping(); 

   //浮动search框
   $("#headerToolbar").smartFloat();

    var topMain=$(".header").height()+$(".weizhi").height()+$(".search_list").height()+$(".mian_search").height()+$(".paixu_xz").height()+56;
	var topMain2=$(".header").height()+$(".weizhi").height()+$(".search_list").height()+$(".mian_search").height()+$(".paixu_xz").height()+$(".product_list").height()+56;
	var nav=$(".nav_scroll");
	$(window).scroll(function(){
		if ($(window).scrollTop()>topMain&&$(window).scrollTop()<topMain2){
			nav.css("display","block");
		}
		else if($(window).scrollTop()>topMain2){nav.css("display","none");}
		else {
			nav.css("display","none");
		}
	});
   
});
   

 //输入框回车事件
function addShoppingCartkd13(ob,n){
	if(event.keyCode ==13 ){//回车事件
      $("#buy-s-"+n).click();
  	}
}
//排序选中
function searchProductOrder(type){
	var  nowType = $("#orderByType").val();
	if(type == "PRICE"){
		if(nowType=="PRICE_ASC"){
			type = "PRICE_DESC";
		}else{
			type = "PRICE_ASC";
		}
	}
	$("#orderByType").val(type);
	$("#filterForm").submit();
}

//结果集内搜索
function setChsNameForSearch(){
	$("#filterFormSearchWhere").val($("#s_chsName").val());
	$("#summary").val($("#s_chsName").val());
	$("#filterForm").submit();
}
//关闭搜索条件
//id form表单的搜索条件  type 搜索类型
function searchkeyClose(id,type){
	$("#"+id).val("");
	$("#filterForm").submit();
}

function showProduct3d(title,url){
	$.layer({
	    type: 2,
	    shadeClose: true,
	    title: false,
	    closeBtn: [0, false],
	    shade: [0.8, '#ccc'],
	    border: [0],
	    offset: ['20px',''],
	    area: ['1000px', ($(window).height() - 100) +'px'],
	    iframe: {src: url}
	}); 
}
</script>
<!--内容结束-->
</div>